﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LIB
{
    public class request
    {
        static public string GetClientIP(System.Web.HttpRequest Request)
        {
            //return request.UserHostAddress;
            string user_IP = "";
            if (Request.ServerVariables["HTTP_VIA"] != null)
            {
                user_IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            }
            else
            {
                user_IP = Request.ServerVariables["REMOTE_ADDR"];
            }
            if (string.IsNullOrEmpty(user_IP))
                user_IP = Request.UserHostAddress;
            if ((string.IsNullOrEmpty(user_IP)) || (user_IP == "")) user_IP = "127.0.0.1";
            return user_IP;
        }

    }
}
